<template>
  <div>
    <el-card style="width: 100%; margin: 10px">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item style="text-align: center" label-width="0">

        </el-form-item>
        <el-form-item label="学号">
          <el-input v-model="form.sno" disabled></el-input>
        </el-form-item>
        <el-form-item label="昵称">
          <el-input v-model="form.sname" disabled></el-input>
        </el-form-item>
        <el-form-item label="年级">
          <el-input v-model="form.sgrade" disabled></el-input>
        </el-form-item>
<!--        <el-form-item label="总成绩">-->
<!--          <el-input v-model="form.stotal" disabled></el-input>-->
<!--        </el-form-item>-->

        <el-form-item label="奖学金获得情况">
          <el-input v-model="form.isprice" disabled></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="form.password" show-password></el-input>
        </el-form-item>

      </el-form>
      <div style="text-align: center">
        <el-button type="primary" @click="update">保存</el-button>
      </div>
    </el-card>

  </div>
</template>

<script>

import request from "../../utils/request";

export default {
  name: "Spersonal",
  data() {
    return {
      form: {}
    }
  },
  created() {
    let str = sessionStorage.getItem("users") || "{}"
    this.form = JSON.parse(str)
  },
  methods: {

    update() {
      request.put("/users", this.form).then(res => {
        console.log(res)
        if (res.code === '0') {
          this.$message({
            type: "success",
            message: "更新成功"
          })
          sessionStorage.setItem("users", JSON.stringify(this.form))
          // 触发Layout更新用户信息
          // this.$emit("userInfo")
        } else {
          this.$message({
            type: "error",
            message: res.msg
          })
        }
      })
    }
  }
}
</script>

<style>

</style>